#ifndef __OCFEXTROOM_H__
#define __OCFEXTROOM_H__

#include "ChannelManager.h"
#include "Job.h"

////////////////////////////////////////////////////////////////////////////////
//
class COcfExtRoom: public COcfExtImpl
{
public:
	COcfExtRoom(IUnknown *pIUnkOuter, CDllServer *pcDllServer, COcfExtImplBase* pcBase);
	virtual ~COcfExtRoom();

public:
	virtual HRESULT __stdcall fnInit(USHORT uiServerID, ULONG ulMaxBindX, BYTE byServiceType, IUnknown* pISink);
	virtual HRESULT __stdcall fnUninit();
	virtual HRESULT __stdcall fnSetConfigPath(unsigned char* pszCfgPath);
	virtual HRESULT __stdcall fnGetStatus(LONG* plStatus);
	virtual HRESULT __stdcall fnBind(ULONG ulBindX, ULONG ulIdentity, ULONG ulKey);
	virtual HRESULT __stdcall fnUnbind(ULONG ulBindX, ULONG ulIdentity, ULONG ulKey);
	virtual HRESULT __stdcall fnIn(ULONG ulBindX, ULONG ulIdentity, LONG lLen, unsigned char* pchData);
	virtual HRESULT __stdcall fnRequestAnything(LONG lLenQuery, unsigned char* pchQuery, ULONG ulMaxLenRet, LONG* plLenRet, unsigned char* pchRet);

public:
	virtual HRESULT __stdcall QueryInterfaceEx(REFIID iid, void** ppv);

	void Logging(const char* pszFormat, ...);

	JOBMANAGER &GetJobManager(){ return m_JobManager; }
	CChannelManager &GetChannelManager(){ return m_ChannelManager; }
	
private:
	CChannelManager m_ChannelManager;

	JOBMANAGER m_JobManager;
	int m_iJobThreadCount;
};

extern COcfExtRoom* GetOcfExtRoomInstance();
#define ROOM GetOcfExtRoomInstance()
#define SINK2 ROOM->GetSinkInterface2()
#define SINK3 ROOM->GetSinkInterface3()
#define LOGGING ROOM->Logging
#define JOB ROOM->GetJobManager()
#define CHANNEL ROOM->GetChannelManager()

////////////////////////////////////////////////////////////////////////////////
//
class COcfExtRoomMainControlCenter: public CMainControlCenter
{
public:
	COcfExtRoomMainControlCenter(CLSID& clsidComponent, char* pszFriendlyName, char* pszVerIndProgID, char* pszProgID):CMainControlCenter(clsidComponent, pszFriendlyName, pszVerIndProgID, pszProgID) {}
	virtual ~COcfExtRoomMainControlCenter() {}

public:
	virtual COcfExtImpl* CreateComponent(IUnknown *pIUnkOuter, CDllServer *pcDllServer, COcfExtImplBase* pcBase)
	{
		return new COcfExtRoom(pIUnkOuter, pcDllServer, pcBase);
	}
};

#endif
